var t, e, n = require("../@babel/runtime/helpers/interopRequireDefault")(require("../@babel/runtime/helpers/typeof"));

t = void 0, e = function(t) {
    function e() {
        throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs");
    }
    function r(t, e) {
        return t(e = {
            exports: {}
        }, e.exports), e.exports;
    }
    var o = "undefined" != typeof window ? window : "undefined" != typeof global ? global : "undefined" != typeof self ? self : {}, i = "function" == typeof Symbol && "symbol" == (0, 
    n.default)(Symbol.iterator) ? function(t) {
        return (0, n.default)(t);
    } : function(t) {
        return t && "function" == typeof Symbol && t.constructor === Symbol && t !== Symbol.prototype ? "symbol" : (0, 
        n.default)(t);
    }, u = r(function(t, n) {
        t.exports = function() {
            function t(t) {
                return "function" == typeof t;
            }
            function n() {
                var t = setTimeout;
                return function() {
                    return t(r, 1);
                };
            }
            function r() {
                for (var t = 0; t < A; t += 2) (0, q[t])(q[t + 1]), q[t] = void 0, q[t + 1] = void 0;
                A = 0;
            }
            function u(t, e) {
                var n = arguments, r = this, o = new this.constructor(a);
                void 0 === o[L] && b(o);
                var i = r._state;
                return i ? function() {
                    var t = n[i - 1];
                    M(function() {
                        return m(i, o, t, r._result);
                    });
                }() : v(r, o, t, e), o;
            }
            function s(t) {
                if (t && "object" === (void 0 === t ? "undefined" : i(t)) && t.constructor === this) return t;
                var e = new this(a);
                return l(e, t), e;
            }
            function a() {}
            function c(t) {
                try {
                    return t.then;
                } catch (t) {
                    return N.error = t, N;
                }
            }
            function f(e, n, r) {
                n.constructor === e.constructor && r === u && n.constructor.resolve === s ? function(t, e) {
                    e._state === D ? h(t, e._result) : e._state === F ? p(t, e._result) : v(e, void 0, function(e) {
                        return l(t, e);
                    }, function(e) {
                        return p(t, e);
                    });
                }(e, n) : r === N ? (p(e, N.error), N.error = null) : void 0 === r ? h(e, n) : t(r) ? function(t, e, n) {
                    M(function(t) {
                        var r = !1, o = function(t, e, n, r) {
                            try {
                                t.call(e, n, r);
                            } catch (t) {
                                return t;
                            }
                        }(n, e, function(n) {
                            r || (r = !0, e !== n ? l(t, n) : h(t, n));
                        }, function(e) {
                            r || (r = !0, p(t, e));
                        }, t._label);
                        !r && o && (r = !0, p(t, o));
                    }, t);
                }(e, n, r) : h(e, n);
            }
            function l(t, e) {
                t === e ? p(t, new TypeError("You cannot resolve a promise with itself")) : function(t) {
                    return "function" == typeof t || "object" === (void 0 === t ? "undefined" : i(t)) && null !== t;
                }(e) ? f(t, e, c(e)) : h(t, e);
            }
            function d(t) {
                t._onerror && t._onerror(t._result), y(t);
            }
            function h(t, e) {
                t._state === I && (t._result = e, t._state = D, 0 !== t._subscribers.length && M(y, t));
            }
            function p(t, e) {
                t._state === I && (t._state = F, t._result = e, M(d, t));
            }
            function v(t, e, n, r) {
                var o = t._subscribers, i = o.length;
                t._onerror = null, o[i] = e, o[i + D] = n, o[i + F] = r, 0 === i && t._state && M(y, t);
            }
            function y(t) {
                var e = t._subscribers, n = t._state;
                if (0 !== e.length) {
                    for (var r = void 0, o = void 0, i = t._result, u = 0; u < e.length; u += 3) r = e[u], 
                    o = e[u + n], r ? m(n, r, o, i) : o(i);
                    t._subscribers.length = 0;
                }
            }
            function _() {
                this.error = null;
            }
            function m(e, n, r, o) {
                var i = t(r), u = void 0, s = void 0, a = void 0, c = void 0;
                if (i) {
                    if ((u = function(t, e) {
                        try {
                            return t(e);
                        } catch (t) {
                            return Y.error = t, Y;
                        }
                    }(r, o)) === Y ? (c = !0, s = u.error, u.error = null) : a = !0, n === u) return void p(n, new TypeError("A promises callback cannot return that same promise."));
                } else u = o, a = !0;
                n._state !== I || (i && a ? l(n, u) : c ? p(n, s) : e === D ? h(n, u) : e === F && p(n, u));
            }
            function b(t) {
                t[L] = B++, t._state = void 0, t._result = void 0, t._subscribers = [];
            }
            function g(t, e) {
                this._instanceConstructor = t, this.promise = new t(a), this.promise[L] || b(this.promise), 
                x(e) ? (this._input = e, this.length = e.length, this._remaining = e.length, this._result = new Array(this.length), 
                0 === this.length ? h(this.promise, this._result) : (this.length = this.length || 0, 
                this._enumerate(), 0 === this._remaining && h(this.promise, this._result))) : p(this.promise, new Error("Array Methods must be provided an Array"));
            }
            function w(t) {
                this[L] = B++, this._result = this._state = void 0, this._subscribers = [], a !== t && ("function" != typeof t && function() {
                    throw new TypeError("You must pass a resolver function as the first argument to the promise constructor");
                }(), this instanceof w ? function(t, e) {
                    try {
                        e(function(e) {
                            l(t, e);
                        }, function(e) {
                            p(t, e);
                        });
                    } catch (e) {
                        p(t, e);
                    }
                }(this, t) : function() {
                    throw new TypeError("Failed to construct 'Promise': Please use the 'new' operator, this object constructor cannot be called as a function.");
                }());
            }
            var x = Array.isArray ? Array.isArray : function(t) {
                return "[object Array]" === Object.prototype.toString.call(t);
            }, A = 0, k = void 0, j = void 0, M = function(t, e) {
                q[A] = t, q[A + 1] = e, 2 === (A += 2) && (j ? j(r) : C());
            }, S = "undefined" != typeof window ? window : void 0, P = S || {}, O = P.MutationObserver || P.WebKitMutationObserver, E = "undefined" == typeof self && "undefined" != typeof process && "[object process]" === {}.toString.call(process), T = "undefined" != typeof Uint8ClampedArray && "undefined" != typeof importScripts && "undefined" != typeof MessageChannel, q = new Array(1e3), C = void 0;
            C = E ? function() {
                return process.nextTick(r);
            } : O ? function() {
                var t = 0, e = new O(r), n = document.createTextNode("");
                return e.observe(n, {
                    characterData: !0
                }), function() {
                    n.data = t = ++t % 2;
                };
            }() : T ? function() {
                var t = new MessageChannel();
                return t.port1.onmessage = r, function() {
                    return t.port2.postMessage(0);
                };
            }() : void 0 === S ? function() {
                try {
                    var t = e();
                    return void 0 !== (k = t.runOnLoop || t.runOnContext) ? function() {
                        k(r);
                    } : n();
                } catch (t) {
                    return n();
                }
            }() : n();
            var L = Math.random().toString(36).substring(16), I = void 0, D = 1, F = 2, N = new _(), Y = new _(), B = 0;
            return g.prototype._enumerate = function() {
                for (var t = this.length, e = this._input, n = 0; this._state === I && n < t; n++) this._eachEntry(e[n], n);
            }, g.prototype._eachEntry = function(t, e) {
                var n = this._instanceConstructor, r = n.resolve;
                if (r === s) {
                    var o = c(t);
                    if (o === u && t._state !== I) this._settledAt(t._state, e, t._result); else if ("function" != typeof o) this._remaining--, 
                    this._result[e] = t; else if (n === w) {
                        var i = new n(a);
                        f(i, t, o), this._willSettleAt(i, e);
                    } else this._willSettleAt(new n(function(e) {
                        return e(t);
                    }), e);
                } else this._willSettleAt(r(t), e);
            }, g.prototype._settledAt = function(t, e, n) {
                var r = this.promise;
                r._state === I && (this._remaining--, t === F ? p(r, n) : this._result[e] = n), 
                0 === this._remaining && h(r, this._result);
            }, g.prototype._willSettleAt = function(t, e) {
                var n = this;
                v(t, void 0, function(t) {
                    return n._settledAt(D, e, t);
                }, function(t) {
                    return n._settledAt(F, e, t);
                });
            }, w.all = function(t) {
                return new g(this, t).promise;
            }, w.race = function(t) {
                var e = this;
                return new e(x(t) ? function(n, r) {
                    for (var o = t.length, i = 0; i < o; i++) e.resolve(t[i]).then(n, r);
                } : function(t, e) {
                    return e(new TypeError("You must pass an array to race."));
                });
            }, w.resolve = s, w.reject = function(t) {
                var e = new this(a);
                return p(e, t), e;
            }, w._setScheduler = function(t) {
                j = t;
            }, w._setAsap = function(t) {
                M = t;
            }, w._asap = M, w.prototype = {
                constructor: w,
                then: u,
                catch: function(t) {
                    return this.then(null, t);
                }
            }, w.polyfill = function() {
                var t = void 0;
                if (void 0 !== o) t = o; else if ("undefined" != typeof self) t = self; else try {
                    t = Function("return this")();
                } catch (t) {
                    throw new Error("polyfill failed because global object is unavailable in this environment");
                }
                var e = t.Promise;
                if (e) {
                    var n = null;
                    try {
                        n = Object.prototype.toString.call(e.resolve());
                    } catch (t) {}
                    if ("[object Promise]" === n && !e.cast) return;
                }
                t.Promise = w;
            }, w.Promise = w, w;
        }();
    }), s = function(t, e, n, r) {
        for (var o = t.length, i = n + (r ? 1 : -1); r ? i-- : ++i < o; ) if (e(t[i], i, t)) return i;
        return -1;
    }, a = function(t) {
        return t != t;
    }, c = function(t, e, n) {
        for (var r = n - 1, o = t.length; ++r < o; ) if (t[r] === e) return r;
        return -1;
    }, f = function(t, e, n) {
        return e == e ? c(t, e, n) : s(t, a, n);
    }, l = Array.isArray, d = function() {}, h = r(function(t, e) {
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = function(t) {
            return function() {
                if (null === t) throw new Error("Callback was already called.");
                var e = t;
                t = null, e.apply(this, arguments);
            };
        }, t.exports = e.default;
    }), p = r(function(t, e) {
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = function(t, e) {
            e |= 0;
            for (var n = Math.max(t.length - e, 0), r = Array(n), o = 0; o < n; o++) r[o] = t[e + o];
            return r;
        }, t.exports = e.default;
    }), v = r(function(t, e) {
        function n(t) {
            setTimeout(t, 0);
        }
        function r(t) {
            return function(e) {
                var n = (0, u.default)(arguments, 1);
                t(function() {
                    e.apply(null, n);
                });
            };
        }
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.hasNextTick = e.hasSetImmediate = void 0, e.fallback = n, e.wrap = r;
        var o, u = function(t) {
            return t && t.__esModule ? t : {
                default: t
            };
        }(p), s = e.hasSetImmediate = "function" == typeof setImmediate && setImmediate, a = e.hasNextTick = "object" === ("undefined" == typeof process ? "undefined" : i(process)) && "function" == typeof process.nextTick;
        o = s ? setImmediate : a ? process.nextTick : n, e.default = r(o);
    }), y = r(function(t, e) {
        function n() {
            this.head = this.tail = null, this.length = 0;
        }
        function r(t, e) {
            t.length = 1, t.head = t.tail = e;
        }
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = n, n.prototype.removeLink = function(t) {
            return t.prev ? t.prev.next = t.next : this.head = t.next, t.next ? t.next.prev = t.prev : this.tail = t.prev, 
            t.prev = t.next = null, this.length -= 1, t;
        }, n.prototype.empty = function() {
            for (;this.head; ) this.shift();
            return this;
        }, n.prototype.insertAfter = function(t, e) {
            e.prev = t, e.next = t.next, t.next ? t.next.prev = e : this.tail = e, t.next = e, 
            this.length += 1;
        }, n.prototype.insertBefore = function(t, e) {
            e.prev = t.prev, e.next = t, t.prev ? t.prev.next = e : this.head = e, t.prev = e, 
            this.length += 1;
        }, n.prototype.unshift = function(t) {
            this.head ? this.insertBefore(this.head, t) : r(this, t);
        }, n.prototype.push = function(t) {
            this.tail ? this.insertAfter(this.tail, t) : r(this, t);
        }, n.prototype.shift = function() {
            return this.head && this.removeLink(this.head);
        }, n.prototype.pop = function() {
            return this.tail && this.removeLink(this.tail);
        }, n.prototype.toArray = function() {
            for (var t = Array(this.length), e = this.head, n = 0; n < this.length; n++) t[n] = e.data, 
            e = e.next;
            return t;
        }, n.prototype.remove = function(t) {
            for (var e = this.head; e; ) {
                var n = e.next;
                t(e) && this.removeLink(e), e = n;
            }
            return this;
        }, t.exports = e.default;
    }), _ = function(t) {
        var e = void 0 === t ? "undefined" : i(t);
        return null != t && ("object" == e || "function" == e);
    }, m = r(function(t, e) {
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = function(t) {
            return function() {
                var e = (0, n.default)(arguments), r = e.pop();
                t.call(this, e, r);
            };
        };
        var n = function(t) {
            return t && t.__esModule ? t : {
                default: t
            };
        }(p);
        t.exports = e.default;
    }), b = r(function(t, e) {
        function n(t) {
            return t && t.__esModule ? t : {
                default: t
            };
        }
        function r(t, e, n) {
            try {
                t(e, n);
            } catch (t) {
                (0, s.default)(o, t);
            }
        }
        function o(t) {
            throw t;
        }
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = function(t) {
            return (0, u.default)(function(e, n) {
                var o;
                try {
                    o = t.apply(this, e);
                } catch (t) {
                    return n(t);
                }
                (0, i.default)(o) && "function" == typeof o.then ? o.then(function(t) {
                    r(n, null, t);
                }, function(t) {
                    r(n, t.message ? t : new Error(t));
                }) : n(null, o);
            });
        };
        var i = n(_), u = n(m), s = n(v);
        t.exports = e.default;
    }), g = r(function(t, e) {
        function n(t) {
            return o && "AsyncFunction" === t[Symbol.toStringTag];
        }
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.isAsync = void 0;
        var r = function(t) {
            return t && t.__esModule ? t : {
                default: t
            };
        }(b), o = "function" == typeof Symbol;
        e.default = function(t) {
            return n(t) ? (0, r.default)(t) : t;
        }, e.isAsync = n;
    }), w = r(function(t, e) {
        function n(t) {
            return t && t.__esModule ? t : {
                default: t
            };
        }
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = function(t, e, n) {
            function f(t, e, n) {
                if (null != n && "function" != typeof n) throw new Error("task callback must be a function");
                if (y.started = !0, (0, o.default)(t) || (t = [ t ]), 0 === t.length && y.idle()) return (0, 
                s.default)(function() {
                    y.drain();
                });
                for (var r = 0, u = t.length; r < u; r++) {
                    var a = {
                        data: t[r],
                        callback: n || i.default
                    };
                    e ? y._tasks.unshift(a) : y._tasks.push(a);
                }
                (0, s.default)(y.process);
            }
            function l(t) {
                return function(e) {
                    h -= 1;
                    for (var n = 0, o = t.length; n < o; n++) {
                        var i = t[n], u = (0, r.default)(p, i, 0);
                        u >= 0 && p.splice(u), i.callback.apply(i, arguments), null != e && y.error(e, i.data);
                    }
                    h <= y.concurrency - y.buffer && y.unsaturated(), y.idle() && y.drain(), y.process();
                };
            }
            if (null == e) e = 1; else if (0 === e) throw new Error("Concurrency must not be zero");
            var d = (0, c.default)(t), h = 0, p = [], v = !1, y = {
                _tasks: new a.default(),
                concurrency: e,
                payload: n,
                saturated: i.default,
                unsaturated: i.default,
                buffer: e / 4,
                empty: i.default,
                drain: i.default,
                error: i.default,
                started: !1,
                paused: !1,
                push: function(t, e) {
                    f(t, !1, e);
                },
                kill: function() {
                    y.drain = i.default, y._tasks.empty();
                },
                unshift: function(t, e) {
                    f(t, !0, e);
                },
                remove: function(t) {
                    y._tasks.remove(t);
                },
                process: function() {
                    if (!v) {
                        for (v = !0; !y.paused && h < y.concurrency && y._tasks.length; ) {
                            var t = [], e = [], n = y._tasks.length;
                            y.payload && (n = Math.min(n, y.payload));
                            for (var r = 0; r < n; r++) {
                                var o = y._tasks.shift();
                                t.push(o), e.push(o.data);
                            }
                            h += 1, p.push(t[0]), 0 === y._tasks.length && y.empty(), h === y.concurrency && y.saturated();
                            var i = (0, u.default)(l(t));
                            d(e, i);
                        }
                        v = !1;
                    }
                },
                length: function() {
                    return y._tasks.length;
                },
                running: function() {
                    return h;
                },
                workersList: function() {
                    return p;
                },
                idle: function() {
                    return y._tasks.length + h === 0;
                },
                pause: function() {
                    y.paused = !0;
                },
                resume: function() {
                    !1 !== y.paused && (y.paused = !1, (0, s.default)(y.process));
                }
            };
            return y;
        };
        var r = n(f), o = n(l), i = n(d), u = n(h), s = n(v), a = n(y), c = n(g);
        t.exports = e.default;
    }), x = function(t) {
        return t && t.__esModule ? t.default : t;
    }(r(function(t, e) {
        function n(t) {
            return t && t.__esModule ? t : {
                default: t
            };
        }
        Object.defineProperty(e, "__esModule", {
            value: !0
        }), e.default = function(t, e) {
            var n = (0, o.default)(t);
            return (0, r.default)(function(t, e) {
                n(t[0], e);
            }, e, 1);
        };
        var r = n(w), o = n(g);
        t.exports = e.default;
    })), A = {
        request: wx.request,
        Promise: u,
        concurrency: 10
    }, k = x(function(t, e) {
        return t(e);
    }, A.concurrency);
    t.request = function(t) {
        return new A.Promise(function(e, n) {
            k.push(function(r) {
                A.request(Object.assign({}, t, {
                    success: e,
                    fail: n,
                    complete: r
                }));
            });
        });
    }, t.setConfig = function(t) {
        var e = t.concurrency !== A.concurrency;
        A = Object.assign({}, A, t), e && (k.concurrency = A.concurrency);
    }, t.Promise = u, Object.defineProperty(t, "__esModule", {
        value: !0
    });
}, "object" == ("undefined" == typeof exports ? "undefined" : (0, n.default)(exports)) && "undefined" != typeof module ? e(exports) : "function" == typeof define && define.amd ? define([ "exports" ], e) : e(t["wx-promise-request"] = t["wx-promise-request"] || {});